﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
using System.Media;
using System.Drawing.Drawing2D;
using System.Collections;


namespace H_GAME
{
    public partial class fmrMain : Form
    {

        public static string Player = "1"; //玩家选择
        public static int CpuCount = 3; //电脑人数
        public static int CpuHardLevel = 5; //电脑难度
        public static int Silder_Cpu = 0; //电脑士兵
        public static int Silder_Plyer = 0; //电脑士兵
        public static bool PlayerAuto = false; //电脑难度
        public static bool IsDevModel = false; //开发者模式
        public static int HelpCpuCount = 1;    //协助者

        public static string CurrentMusicPath = "";

        public const int MM_MCINOTIFY = 0x3B9;  //这是声明 播完音乐 mciSendString（）向系统发送的指令

        public static bool CloseFlag = false;

        [DllImport("winmm.dll")]
        private static extern long mciSendString(string command,
                                                    StringBuilder returnString,
                                                    int returnSize,
                                                    IntPtr hwndCallback);

        ArrayList AllRoleObjects = new ArrayList();//所有角色对象 

        Cls_Hammer[] hammers;

        Cls_Soldier[] Soldiers;

        //关卡设置
        Cls_Stage stage1;
        //private int earthint = 20;//重力
        public string speechstr = "";

        public fmrMain()
        {
            InitializeComponent();

            frmConfigSet fc = new frmConfigSet();
            fc.ShowDialog();

           
        }

        protected override void DefWndProc(ref Message m)
        {
            base.DefWndProc(ref m);

            if (m.Msg == MM_MCINOTIFY) //判断指令是不是MM_MCINOTIFY

            //当歌曲播完 mciSendString（）向系统发送的MM_MCINOTIFY指令
            {
                PlaySong(CurrentMusicPath);//播完就自动播放这个。。。
            }
        }


        public void PlaySong(string file)
        {
            mciSendString("close media", null, 0, IntPtr.Zero);//关闭
            mciSendString("open \"" + file + "\" type mpegvideo alias media", null, 0, IntPtr.Zero);

            //打开  file 这个路径的歌曲 " ，type mpegvideo是文件类型  ，    alias 是将文件别名为media 
            mciSendString("play media notify", null, 0, this.Handle);//播放
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
          
        }

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
           
           
              ObjectsPaint(e.Graphics); //绘制对象
          
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            for (int i = 0; i < AllRoleObjects.Count; i++)
            {
                if (AllRoleObjects[i].GetType().ToString().Contains("Cls_Hammer"))
                {
                    Cls_Hammer tempobj = (Cls_Hammer)AllRoleObjects[i];
                    HummerTimerRefresh(tempobj); //女战士1Hummer
                }
                else if (AllRoleObjects[i].GetType().ToString().Contains("Cls_Soldier"))
                {
                    Cls_Soldier tempobj = (Cls_Soldier)AllRoleObjects[i];
                    SoldiersTimerRefresh(tempobj);//女士兵2
                }

                
            }
               

            pictureBox1.Refresh(); 
           
        }

        #region 原来代码
        ///// <summary>
        ///// 士兵绘制
        ///// </summary>
        //public void SoldiersPaint(Graphics e)
        //{
        //    //女士兵
        //    for (int i = 0; i < Soldiers.Length; i++)
        //    {
        //        Soldiers[i].GetImgAction(e);
        //        if (IsDevModel)
        //        {
        //            Pen pn_act = new Pen(Color.Yellow);
        //            Pen pn_def = new Pen(Color.Blue);
        //            Pen pn_body = new Pen(Color.DarkGreen);


        //            //显示攻击区域
        //            e.DrawRectangle(pn_act, Soldiers[i].Actrec);
        //            //显示防守区域
        //            e.DrawRectangle(pn_def, Soldiers[i].Defrec);
        //            //显示有效受力区域
        //            e.DrawRectangle(pn_body, Soldiers[i].Bodyrec);
        //        }

        //    }
        //}

        ///// <summary>
        ///// 女战士图像绘制
        ///// </summary>
        ///// <param name="e"></param>
        //public void HummerPaint(Graphics e)
        //{
        //    for (int i = 0; i < hammers.Length; i++)
        //    {
        //        if (hammers[i].Isplayer)
        //        {
        //            hammers[i].GetHeadLiveImg(e);
        //            if (hammers[hammers[i].CurrentTargetIndex].Live > 0)
        //                hammers[hammers[i].CurrentTargetIndex].GetHeadLiveImg(e);
        //        }

        //        hammers[i].GetImgAction(e);

        //        if (IsDevModel)
        //        {
        //            Pen pn_act = new Pen(Color.Yellow);
        //            Pen pn_def = new Pen(Color.Blue);
        //            Pen pn_body = new Pen(Color.DarkGreen);


        //            //显示攻击区域
        //            e.DrawRectangle(pn_act, hammers[i].Actrec);
        //            //显示防守区域
        //            e.DrawRectangle(pn_def, hammers[i].Defrec);
        //            //显示有效受力区域
        //            e.DrawRectangle(pn_body, hammers[i].Bodyrec);
        //        }
        //    }   
        //}
        #endregion


        /// <summary>
        /// 女战士图像绘制
        /// </summary>
        /// <param name="e"></param>
        public void ObjectsPaint(Graphics e)
        {
            for (int i = 0; i < AllRoleObjects.Count; i++)
            {
                if (AllRoleObjects[i].GetType().ToString().Contains("Cls_Hammer"))
                {
                    #region Hammer
                    Cls_Hammer objTemp = (Cls_Hammer)AllRoleObjects[i];

                    if (objTemp.Isplayer)
                    {
                        objTemp.GetHeadLiveImg(e);

                        if (AllRoleObjects[objTemp.CurrentTargetIndex].GetType().ToString().Contains("Cls_Hammer"))
                        {

                            Cls_Hammer targetobj = (Cls_Hammer)AllRoleObjects[objTemp.CurrentTargetIndex];
                            targetobj.GetHeadLiveImg(e);
                        }
                        else if (AllRoleObjects[objTemp.CurrentTargetIndex].GetType().ToString().Contains("Cls_Soldier"))
                        {
                            Cls_Soldier targetobj = (Cls_Soldier)AllRoleObjects[objTemp.CurrentTargetIndex];
                            targetobj.GetHeadLiveImg(e);
                        }
                        
                    }
                  

                    objTemp.GetImgAction(e);

                    if (IsDevModel)
                    {
                        Pen pn_act = new Pen(Color.Yellow);
                        Pen pn_def = new Pen(Color.Blue);
                        Pen pn_body = new Pen(Color.DarkGreen);

                        //显示攻击区域
                        e.DrawRectangle(pn_act, objTemp.Actrec);
                        //显示防守区域
                        e.DrawRectangle(pn_def, objTemp.Defrec);
                        //显示有效受力区域
                        e.DrawRectangle(pn_body, objTemp.Bodyrec);
                    }
                    #endregion
                }
                else if (AllRoleObjects[i].GetType().ToString().Contains("Cls_Soldier"))
                {
                    #region Soldier
                    Cls_Soldier objTemp = (Cls_Soldier)AllRoleObjects[i];

                    if (objTemp.Isplayer)
                    {
                        objTemp.GetHeadLiveImg(e);
                        if (AllRoleObjects[objTemp.CurrentTargetIndex].GetType().ToString().Contains("Cls_Hammer"))
                        {
                            Cls_Hammer targetobj = (Cls_Hammer)AllRoleObjects[objTemp.CurrentTargetIndex];
                            targetobj.GetHeadLiveImg(e);
                        }
                        else if (AllRoleObjects[objTemp.CurrentTargetIndex].GetType().ToString().Contains("Cls_Soldier"))
                        {
                            Cls_Soldier targetobj = (Cls_Soldier)AllRoleObjects[objTemp.CurrentTargetIndex];
                            targetobj.GetHeadLiveImg(e);
                        }

                    }

                   
                    objTemp.GetImgAction(e);

                    if (IsDevModel)
                    {
                        Pen pn_act = new Pen(Color.Yellow);
                        Pen pn_def = new Pen(Color.Blue);
                        Pen pn_body = new Pen(Color.DarkGreen);

                        //显示攻击区域
                        e.DrawRectangle(pn_act, objTemp.Actrec);
                        //显示防守区域
                        e.DrawRectangle(pn_def, objTemp.Defrec);
                        //显示有效受力区域
                        e.DrawRectangle(pn_body, objTemp.Bodyrec);
                    }
                    #endregion
                }


            }
        }

        /// <summary>
        /// 女士兵
        /// </summary>
        public void SoldiersTimerRefresh(Cls_Soldier nowTemp)
        {
            
            nowTemp.Targetrecs = new System.Collections.ArrayList();
            if (nowTemp != null)
            {

                for (int k1 = 0; k1 < AllRoleObjects.Count; k1++)
                {
                    //获取敌人位置
                    //hammer
                    if (AllRoleObjects[k1].ToString().Contains("Cls_Hammer"))
                    {
                        Cls_Hammer tempObj = (Cls_Hammer)AllRoleObjects[k1];
                        if (nowTemp.Team != tempObj.Team &&
                            nowTemp.Name != tempObj.Name)
                        {
                            nowTemp.Targetrecs.Add(tempObj);
                        }
                    }
                    else if (AllRoleObjects[k1].ToString().Contains("Cls_Soldier"))
                    {
                        Cls_Soldier tempObj = (Cls_Soldier)AllRoleObjects[k1];
                        if (nowTemp.Team != tempObj.Team &&
                            nowTemp.Name != tempObj.Name)
                        {
                            nowTemp.Targetrecs.Add(tempObj);
                        }
                    }
                }
                nowTemp.ImgMove();
                //nowTemp.Auto();

                if (nowTemp.X < 0)
                {
                    nowTemp.X = 0;
                }
                else if (nowTemp.X > this.Width - nowTemp.Img.Width)
                {
                    nowTemp.X = this.Width - nowTemp.Img.Width - 1;
                }


                #region 声音判断
                //if (i == 0)
                //{
                //    if (speechstr.Contains("左"))
                //    {
                //        hammers[i].Func = "L";
                //    }
                //    else if (speechstr.Contains("右"))
                //    {
                //        hammers[i].Func = "R";
                //    }
                //    else if (speechstr.Contains("走"))
                //    {
                //        hammers[i].Imgtype = "Z";
                //    }
                //    else if (speechstr.Contains("停"))
                //    {
                //        hammers[i].Imgtype = "S";
                //    }
                //    else if (speechstr.Contains("蹲"))
                //    {
                //        hammers[i].Imgtype = "D";
                //    }
                //    else if (speechstr.Contains("攻"))
                //    {
                //        hammers[i].Imgtype = "A1";
                //    }
                //    else if (speechstr.Contains("休"))
                //    {
                //        hammers[i].Imgtype = "V";
                //    }
                //    else if (speechstr.Contains("跳"))
                //    {
                //        hammers[i].Imgtype = "JP";
                //    }
                //    else if (speechstr.Contains("防"))
                //    {
                //        if (hammers[i].Imgtype == "S")
                //        {
                //            hammers[i].Imgtype = "DefS";
                //        }
                //        else if (hammers[i].Imgtype == "D")
                //        {
                //            hammers[i].Imgtype = "DefD";
                //        }
                //    }

                //}
                #endregion

                #region 是否被攻击
                for (int t1 = 0; t1 < AllRoleObjects.Count; t1++)
                {

                    if (AllRoleObjects[t1].ToString().Contains("Cls_Hammer"))
                    {
                        Cls_Hammer tempObj = (Cls_Hammer)AllRoleObjects[t1];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (nowTemp.Live > 0)
                            {
                                if (tempObj.Actrec.X != -1)
                                {
                                    //防守
                                    if (!nowTemp.isBitDef(tempObj.Actrec))
                                    {
                                        //是否被敌方击打

                                        nowTemp.isBitHit(tempObj.Actrec, tempObj.Destroyedval);
                                        if (nowTemp.Isplayer)
                                        {
                                            nowTemp.CurrentTargetIndex = t1;
                                            nowTemp.CurrentTargetName = tempObj.Name;
                                        }
                                    }
                                }

                            }
                        }
                    }
                    else if (AllRoleObjects[t1].ToString().Contains("Cls_Soldier"))
                    {
                        Cls_Soldier tempObj = (Cls_Soldier)AllRoleObjects[t1];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (nowTemp.Live > 0)
                            {
                                if (tempObj.Actrec.X != -1)
                                {
                                    //防守
                                    if (!nowTemp.isBitDef(tempObj.Actrec))
                                    {
                                        //是否被敌方击打
                                        nowTemp.isBitHit(tempObj.Actrec, tempObj.Destroyedval);
                                        if (nowTemp.Isplayer)
                                        {
                                            nowTemp.CurrentTargetIndex = t1;
                                            nowTemp.CurrentTargetName = tempObj.Name;
                                        }
                                    }
                                }

                            }
                        }
                    }



                }
                #endregion

                #region 北打击后的状态判断
                if (nowTemp.Live > 0)
                {
                    if (nowTemp.Isbyhit)
                    {
                        nowTemp.Imgtype = "ByBitS";
                    }
                }
                else
                {
                    nowTemp.Imgtype = "DT1";
                }
                #endregion

                #region 判断是否胜利
                nowTemp.Isvictory = true;
                for (int t2 = 0; t2 < AllRoleObjects.Count; t2++)
                {
                    if (AllRoleObjects[t2].ToString().Contains("Cls_Hammer"))
                    {
                        Cls_Hammer tempObj = (Cls_Hammer)AllRoleObjects[t2];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (tempObj.Live > 0)
                                nowTemp.Isvictory = false;
                        }
                    }
                    else if (AllRoleObjects[t2].ToString().Contains("Cls_Soldier"))
                    {
                        Cls_Soldier tempObj = (Cls_Soldier)AllRoleObjects[t2];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (tempObj.Live > 0)
                                nowTemp.Isvictory = false;
                        }
                    }
                }
                #endregion
            }
        }

       

        /// <summary>
        /// 女战士时间动作
        /// </summary>
        public void HummerTimerRefresh(Cls_Hammer nowTemp)
        {

            nowTemp.Targetrecs = new System.Collections.ArrayList();
            if (nowTemp != null)
            {

                for (int k1 = 0; k1 < AllRoleObjects.Count; k1++)
                {
                    //获取敌人位置
                    //hammer
                    if (AllRoleObjects[k1].ToString().Contains("Cls_Hammer"))
                    {
                        Cls_Hammer tempObj = (Cls_Hammer)AllRoleObjects[k1];
                        if (nowTemp.Team != tempObj.Team &&
                            nowTemp.Name != tempObj.Name)
                        {
                            nowTemp.Targetrecs.Add(tempObj);
                        }
                    }
                    else if (AllRoleObjects[k1].ToString().Contains("Cls_Soldier"))
                    {
                        Cls_Soldier tempObj = (Cls_Soldier)AllRoleObjects[k1];
                        if (nowTemp.Team != tempObj.Team &&
                            nowTemp.Name != tempObj.Name)
                        {
                            nowTemp.Targetrecs.Add(tempObj);
                        }
                    }
                }
                nowTemp.ImgMove();
                //nowTemp.Auto();
                if (nowTemp.X < 0)
                {
                    nowTemp.X = 0;
                }
                else if (nowTemp.X > this.Width - nowTemp.Img.Width)
                {
                    nowTemp.X = this.Width - nowTemp.Img.Width - 1;
                }

                #region 声音判断
                //if (i == 0)
                //{
                //    if (speechstr.Contains("左"))
                //    {
                //        hammers[i].Func = "L";
                //    }
                //    else if (speechstr.Contains("右"))
                //    {
                //        hammers[i].Func = "R";
                //    }
                //    else if (speechstr.Contains("走"))
                //    {
                //        hammers[i].Imgtype = "Z";
                //    }
                //    else if (speechstr.Contains("停"))
                //    {
                //        hammers[i].Imgtype = "S";
                //    }
                //    else if (speechstr.Contains("蹲"))
                //    {
                //        hammers[i].Imgtype = "D";
                //    }
                //    else if (speechstr.Contains("攻"))
                //    {
                //        hammers[i].Imgtype = "A1";
                //    }
                //    else if (speechstr.Contains("休"))
                //    {
                //        hammers[i].Imgtype = "V";
                //    }
                //    else if (speechstr.Contains("跳"))
                //    {
                //        hammers[i].Imgtype = "JP";
                //    }
                //    else if (speechstr.Contains("防"))
                //    {
                //        if (hammers[i].Imgtype == "S")
                //        {
                //            hammers[i].Imgtype = "DefS";
                //        }
                //        else if (hammers[i].Imgtype == "D")
                //        {
                //            hammers[i].Imgtype = "DefD";
                //        }
                //    }

                //}
                #endregion

                #region 是否被攻击
                for (int t1 = 0; t1 < AllRoleObjects.Count; t1++)
                {

                    if (AllRoleObjects[t1].ToString().Contains("Cls_Hammer"))
                    {
                        Cls_Hammer tempObj = (Cls_Hammer)AllRoleObjects[t1];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (nowTemp.Live > 0)
                            {
                                if (tempObj.Actrec.X != -1)
                                {
                                    //防守
                                    if (!nowTemp.isBitDef(tempObj.Actrec))
                                    {
                                        //是否被敌方击打

                                        nowTemp.isBitHit(tempObj.Actrec, tempObj.Destroyedval);
                                        if (nowTemp.Isplayer)
                                        {
                                            nowTemp.CurrentTargetIndex = t1;
                                            nowTemp.CurrentTargetName = tempObj.Name;
                                        }
                                    }
                                }

                            }
                        }
                    }
                    else if (AllRoleObjects[t1].ToString().Contains("Cls_Soldier"))
                    {
                        Cls_Soldier tempObj = (Cls_Soldier)AllRoleObjects[t1];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (nowTemp.Live > 0)
                            {
                                if (tempObj.Actrec.X != -1)
                                {
                                    //防守
                                    if (!nowTemp.isBitDef(tempObj.Actrec))
                                    {
                                        //是否被敌方击打
                                        nowTemp.isBitHit(tempObj.Actrec, tempObj.Destroyedval);
                                        if (nowTemp.Isplayer)
                                        {
                                            nowTemp.CurrentTargetIndex = t1;
                                            nowTemp.CurrentTargetName = tempObj.Name;
                                        }

                                    }
                                }

                            }
                        }
                    }



                }
                #endregion

                #region 北打击后的状态判断
                if (nowTemp.Live > 0)
                {
                    if (nowTemp.Isbyhit)
                    {
                        // 如果被集中的话持续动作
                        if (nowTemp.Imgtype != "D" ||
                            nowTemp.Imgtype != "A3")
                            nowTemp.Imgtype = "ByBitD";
                        else
                            nowTemp.Imgtype = "ByBitS";
                    }
                }
                else
                {
                    nowTemp.Imgtype = "DT1";
                }
                #endregion

                #region 判断是否胜利
                nowTemp.Isvictory = true;
                for (int t2 = 0; t2 < AllRoleObjects.Count; t2++)
                {
                    if (AllRoleObjects[t2].ToString().Contains("Cls_Hammer"))
                    {
                        Cls_Hammer tempObj = (Cls_Hammer)AllRoleObjects[t2];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (tempObj.Live > 0)
                                nowTemp.Isvictory = false;
                        }
                    }
                    else if (AllRoleObjects[t2].ToString().Contains("Cls_Soldier"))
                    {
                        Cls_Soldier tempObj = (Cls_Soldier)AllRoleObjects[t2];
                        if (nowTemp.Team != tempObj.Team)
                        {
                            if (tempObj.Live > 0)
                                nowTemp.Isvictory = false;
                        }
                    } 
                }
                #endregion
            }
            
        }


        private void pictureBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
           
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            for (int i = 0; i < hammers.Length; i++)
            {
                if (hammers[i] != null)
                {
                    if (hammers[i].Isfinished && hammers[i].Isplayer)
                    {
                        if (e.KeyCode == Keys.Down)
                        {
                            hammers[i].Imgtype = "D";
                        }
                        else if (e.KeyCode == Keys.Right)
                        {
                            hammers[i].Func = "R";
                            hammers[i].Imgtype = "Z";
                        }
                        else if (e.KeyCode == Keys.Left)
                        {
                            hammers[i].Func = "L";
                            hammers[i].Imgtype = "Z";
                        }
                        else if (e.KeyCode == Keys.V)
                        {
                            hammers[i].Imgindex = 0;
                            hammers[i].Imgtype = "V";
                        }
                        else if (e.KeyCode == Keys.A)
                        {
                            hammers[i].Imgindex = 0;
                            hammers[i].Imgtype = "A1";
                        }
                        else if (e.KeyCode == Keys.S)
                        {
                            hammers[i].Imgindex = 0;
                            hammers[i].Imgtype = "A2";
                        }
                        else if (e.KeyCode == Keys.Z)
                        {
                            hammers[i].Imgindex = 0;
                            hammers[i].Imgtype = "A3";
                        }
                        else if (e.KeyCode == Keys.X)
                        {
                            hammers[i].Imgindex = 0;
                            hammers[i].Imgtype = "A4";
                        }
                        else if (e.KeyCode == Keys.D)
                        {
                            hammers[i].Imgindex = 0;
                            hammers[i].Imgtype = "DefD";
                        }
                        else if (e.KeyCode == Keys.F)
                        {
                            hammers[i].Imgtype = "DefS";
                        }
                        else if (e.KeyCode == Keys.Up)
                        {
                            //跳跃
                            if (hammers[i].Imgtype != "JP")
                            {
                                hammers[i].Imgindex = 0;
                                hammers[i].Imgtype = "JP";
                            }
                        }
                        else if (e.KeyCode == Keys.Q)
                        {
                            //被击倒
                            hammers[i].Imgtype = "DT2";
                            hammers[i].Imgindex = 0;
                        }
                        else if (e.KeyCode == Keys.G)
                        {
                            //被击蹲
                            hammers[i].Imgtype = "ByBitD";
                            hammers[i].Imgindex = 0;
                        }
                        else if (e.KeyCode == Keys.H)
                        {
                            //被击站立
                            hammers[i].Imgtype = "ByBitS";
                            hammers[i].Imgindex = 0;
                        }
                    }

                }
            }
        }

        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            for (int i = 0; i < hammers.Length; i++)
            {
                if (i == 0)
                {
                    if (hammers[i].Imgtype != "V" && hammers[i].Imgtype != "JP" &&
                        hammers[i].Imgtype != "A1" && hammers[i].Imgtype != "A2" &&
                        hammers[i].Imgtype != "A3" && hammers[i].Imgtype != "A4" && 
                        hammers[i].Imgtype != "DT1" && hammers[i].Imgtype != "ByBitD" && 
                        hammers[i].Imgtype != "ByBitS" &&
                        hammers[i].Imgtype != "DT2" && hammers[i].Imgtype != "DefS" &&
                        hammers[i].Imgtype != "DefD" && hammers[i].Imgtype=="Z")
                           hammers[i].Imgtype = "S";
                }
            }

        }

        public void ShowMessage(string msg)
        {
            //做你想做的
            speechstr = msg;
        }

        /// <summary>
        /// 语音识别
        /// </summary>
        public void Start()
        {
            //SpRecognition sp = SpRecognition.instance();
            //sp.SetMessage += ShowMessage;
            //sp.BeginRec();
        }

       
        private void fmrMain_Load(object sender, EventArgs e)
        {

            if (!CloseFlag)
            {
                //关闭系统
                this.Close();
                return;
            }


            hammers = new Cls_Hammer[CpuCount+HelpCpuCount];
            Soldiers = new Cls_Soldier[Silder_Cpu+Silder_Plyer];

            AllRoleObjects = new ArrayList(CpuCount + HelpCpuCount+1);



            //关卡设置
            stage1 = new Cls_Stage();
            stage1.Musicpath = Application.StartupPath + "\\music\\003.mp3";
            CurrentMusicPath = stage1.Musicpath;
           
            stage1.Imgback = new Bitmap(Application.StartupPath + "\\pic\\stage2\\0014.png");
            stage1.Imgback2 = new Bitmap(Application.StartupPath + "\\pic\\stage2\\0001.png");
            stage1.Imgback3 = new Bitmap(Application.StartupPath + "\\pic\\stage2\\0002.png");
            this.pictureBox1.Image = stage1.GetFixPic(this.pictureBox1.Width, stage1.Imgback.Height);
           
            
            //女战士1
            for (int i = 0; i < hammers.Length; i++)
            {
                hammers[i] = new Cls_Hammer();
                hammers[i].Ini();
                if (i > hammers.Length - HelpCpuCount - 1)
                {
                    Random tn = new Random();
                    hammers[i].Team = 0;
                    hammers[i].Func = "R";
                    hammers[i].X = 0;
                    hammers[i].old_x = hammers[i].X;

                    hammers[i].Autoflag = true;
                    hammers[i].hardindex = 8;
                    hammers[i].Imgpath = Application.StartupPath + "\\Pic\\Hammer" + Player + "";
                    hammers[i].Name = "Hippolyta";

                    if (i == hammers.Length - 1)
                    {
                        //手动玩家
                        hammers[i].Isplayer = true;
                        hammers[i].Autoflag = PlayerAuto;
                        hammers[i].Live = 4000;
                        hammers[i].Defaultdestroyedval = 50;
                    }
                    else
                    {
                        //帮手
                        hammers[i].Autoflag = true;
                        hammers[i].Live = 25000;
                        hammers[i].Defaultdestroyedval = 40;
                    }

                }
                else
                {
                    Random tn = new Random();
                    hammers[i].Team = 1;
                    hammers[i].Func = "L";
                    hammers[i].hardindex = CpuHardLevel;
                    hammers[i].X = tn.Next(this.Width / 2, this.Width - 100);
                    hammers[i].old_x = hammers[i].X;
                    hammers[i].Autoflag = true;
                    int epindex = tn.Next(1, 7);
                    if (epindex.ToString() == Player)
                    {
                        //与玩家人物一致了
                        if (epindex == 7)
                        {
                            epindex = epindex - 1;
                        }
                        else if (epindex == 1)
                        {
                            epindex = epindex + 1;
                        }
                        else
                        {
                            epindex = epindex + 1;
                        }
                    }

                    hammers[i].Imgpath = Application.StartupPath + "\\Pic\\Hammer" + epindex.ToString() + "";
                    hammers[i].Name = "Number" + Convert.ToString(i + 1);
                    hammers[i].Isplayer = false;
                    hammers[i].Defaultdestroyedval = 50;
                    hammers[i].Live = 18000;
                }
                hammers[i].Id = i;
                hammers[i].Img = new Bitmap(hammers[i].Imgpath + "\\S_1.png");
                AllRoleObjects.Add(hammers[i]);
            }

            //士兵
            for (int i = 0; i < Soldiers.Length; i++)
            {
               
                    Soldiers[i] = new Cls_Soldier();
                    Soldiers[i].Ini();
                    Random tn = new Random();
                    if (i < Silder_Cpu)
                    {
                        Soldiers[i].Team = 1;
                        Soldiers[i].Name = "Soldier_" + Convert.ToString(i + 1);
                        Soldiers[i].X = tn.Next(this.Width / 2, this.Width - 100);
                        Soldiers[i].Func = "L";
                    }
                    else
                    {
                        Soldiers[i].Team = 0;
                        Soldiers[i].Name = "MySoldier_" + Convert.ToString(i + 1);
                        Soldiers[i].X = tn.Next(0,this.Width / 2);
                        Soldiers[i].Func = "R";
                    }
                   
                    Soldiers[i].Imgtype = "S";
                   
                    Soldiers[i].old_x = Soldiers[i].X;
                    Soldiers[i].Live = 4000;
                    Soldiers[i].Autoflag = true;
                    Soldiers[i].hardindex = 8;
                    Soldiers[i].Imgpath = Application.StartupPath + "\\Pic\\Soldier";
                    
                    AllRoleObjects.Add(Soldiers[i]);
             
            }




            timer1.Enabled = true;
            timer2.Enabled = true;
            PlaySong(stage1.Musicpath);
            //Start();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            
            this.pictureBox1.Image = stage1.GetFixPic(this.pictureBox1.Width, stage1.Imgback.Height);
        }
    }
}
